package org.dftproject.genesis.ui.pages.place;

import org.dftproject.genesis.data.genealogy.IPlace;
import org.dftproject.genesis.ui.SharedImages;
import org.dftproject.genesis.ui.pages.AbstractPageInput;

public class PlacePageInput extends AbstractPageInput {
	
	private IPlace place;
	
	public PlacePageInput(IPlace place) {
		setPlace(place);
	}
	
	public void setPlace(IPlace place) {
		this.place = place;
		
		setLabel(place.toString());
		
		setImageDescriptor(SharedImages.getDefault().getImageDescriptor(SharedImages.IMG_WORLD));
	}
	
	public IPlace getPlace() {
		return place;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((place == null) ? 0 : place.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final PlacePageInput other = (PlacePageInput) obj;
		if (place == null) {
			if (other.place != null)
				return false;
		} else if (!place.equals(other.place))
			return false;
		return true;
	}

}
